package com.xbts.system.domain;

import com.xbts.system.enums.ArticleEnums;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.Data;
import com.xbts.common.annotation.Excel;
import com.xbts.common.utils.StringUtils;
import com.xbts.common.core.domain.BaseEntity;

/**
 * 文章对象 cn_article
 *
 * @author xbts
 * @date 2023-08-03
 */
@Data
@ApiModel("文章对象")
@TableName("cn_article")
public class CnArticle extends BaseEntity {

private static final long serialVersionUID=1L;

    /** ID */
    @TableId
    private String id;

    /** 文章内容 */
    @Excel(name = "文章内容")
    @ApiModelProperty("文章内容")
    private String content;

    /** 文章类型 */
    @Excel(name = "文章类型")
    @ApiModelProperty("文章类型")
    private ArticleEnums type;

    /** 文章标题 */
    @Excel(name = "文章标题")
    @ApiModelProperty("文章标题")
    private String title;

    public<T> QueryWrapper<T> queryWrapper(){
        QueryWrapper<T> queryWrapper=new QueryWrapper<>();
        queryWrapper.like(StringUtils.isNotEmpty(title),"title",title);
        queryWrapper.like(StringUtils.isNotEmpty(content),"content",content);
        queryWrapper.eq(StringUtils.isNotNull(type),"type",type);
        queryWrapper.orderByDesc("create_time");
        return queryWrapper;
    }
}